package com.ma5d.driver.driver.controller;

import com.ma5d.driver.common.result.Result;
import com.ma5d.driver.driver.service.DriverInfoService;
import com.ma5d.driver.model.form.DriverFaceModelForm;
import com.ma5d.driver.model.form.UpdateDriverAuthInfoForm;
import com.ma5d.driver.model.vo.driver.DriverLoginVo;
import jakarta.annotation.Resource;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/driver/info")
public class DriverInfoController {

    @Resource
    private DriverInfoService driverInfoService;

    @GetMapping("/login/{code}")
    public Result<Long> login(@PathVariable String code) throws WxErrorException {
        return Result.ok(driverInfoService.login(code));
    }

    @GetMapping("/getDriverLoginInfo/{driverId}")
    public Result<DriverLoginVo> getDriverLoginInfo(@PathVariable String driverId) {
        DriverLoginVo driverLoginInfo = driverInfoService.getDriverLoginInfo(driverId);
        return Result.ok(driverLoginInfo);
    }

    @PostMapping("/updateDriverAuthInfo")
    public Result<Boolean> updateDriverAuthInfo(@RequestBody UpdateDriverAuthInfoForm updateDriverAuthInfoForm) {
        Boolean info = driverInfoService.updateDriverAuthInfo(updateDriverAuthInfoForm);
        return Result.ok(info);
    }

    @PostMapping("/createDriverFaceModel")
    public Result<Boolean> createDriverFaceModel(@RequestBody DriverFaceModelForm driverFaceModelForm) {
        Boolean success = driverInfoService.createDriverFaceModel(driverFaceModelForm);
        return Result.ok(success);
    }
}
